---
import { Snippet } from '@ag-website-shared/components/snippet/Snippet';
import he from 'he';
import { getFrameworkFromPath } from '@components/docs/utils/urlPaths';

const framework = getFrameworkFromPath(Astro.url.pathname);

const {
    // NOTE: Language is passed through by markdoc as `data-language`
    // @see https://github.com/markdoc/markdoc/blob/a13cc583fa3b0420538e772a75628dd15d72b793/src/schema.ts#L56
    'data-language': language,
    frameworkTransform,
    ...otherProps
} = Astro.props;

const encodedHtmlContent = await Astro.slots.render('default');
const content = he.decode(encodedHtmlContent);
---

<Snippet framework={framework} language={language} content={content} transform={frameworkTransform} {...otherProps} />
